#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
using namespace std;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
int map[100][100];
bool is_come[100][100];
int seedx,seedy;
struct node
{
    pair<int,int> val;
    node *next;
};
class STACK
{
    public:
        node *head,*tail;
        STACK();
        void push(pair<int,int>val);
        void pop();
        pair<int,int> top();
        bool empty();
};
STACK::STACK()
{
    head=new node;
    head->next=NULL;
    tail=head;
}
void STACK::push(pair<int,int>val)
{
    node *p=new node;
    p->val=val;
    p->next=NULL;
    tail->next=p;
    tail=p;
}
void STACK::pop()
{
    if(head==tail)return ;
    node *p=head;
    while(p->next!=tail)p=p->next;
    p->next=NULL;
    tail=p;
}
pair<int,int> STACK::top()
{
    return tail->val;
}
bool STACK::empty()
{
    return head==tail;
}
void dfs1(int sx,int sy,int n,int m)//链式栈
{
    STACK s;
    s.push(make_pair(sx,sy));
    is_come[sx][sy]=true;
    while(!s.empty())
    {
        int x=s.top().first;
        int y=s.top().second;
        int value=map[x][y];
        s.pop();
        map[x][y]=0;
        for(int k=0;k<4;k++)
        {
            int next_x=x+dx[k];
            int next_y=y+dy[k];
            if(map[next_x][next_y]==value&&x>=1&&x<=n&&y>=1&&y<=m&&!is_come[next_x][next_y])
            {
                is_come[next_x][next_y]=true;
                s.push(make_pair(next_x,next_y));
            }
        }
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>map[i][j];
        }
    }
    memset(is_come,0,sizeof(is_come));
    cin>>seedx>>seedy;
    is_come[seedx][seedy]=true;
    dfs1(seedx,seedy,n,m);
   // map[seedx][seedy]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cout<<map[i][j]<<' ';
        }
        cout<<endl;
    }
    return 0;
}